package cn.iocoder.yudao.module.resource.service.category;

import cn.iocoder.yudao.module.resource.dal.dataobject.category.ResourceCategoryDO;
import cn.iocoder.yudao.module.resource.dal.mysql.category.ResourceCategoryMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 资源分类 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
@Slf4j
public class ResourceCategoryServiceImpl implements ResourceCategoryService {

    @Resource
    private ResourceCategoryMapper categoryMapper;

    @Override
    public Long createCategory(ResourceCategoryDO categoryDO) {
        categoryMapper.insert(categoryDO);
        return categoryDO.getId();
    }

    @Override
    public void updateCategory(ResourceCategoryDO categoryDO) {
        categoryMapper.updateById(categoryDO);
    }

    @Override
    public void deleteCategory(Long id) {
        categoryMapper.deleteById(id);
    }

    @Override
    public ResourceCategoryDO getCategory(Long id) {
        return categoryMapper.selectById(id);
    }

    @Override
    public List<ResourceCategoryDO> getCategoryList() {
        return categoryMapper.selectList();
    }

    @Override
    public List<ResourceCategoryDO> getCategoryListByParentId(Long parentId) {
        return categoryMapper.selectListByParentId(parentId);
    }

    @Override
    public List<ResourceCategoryDO> getCategoryListByStatus(Integer status) {
        return categoryMapper.selectListByStatus(status);
    }

}
